package com.yys.onmyoji.service;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.yys.onmyoji.bean.Text;

import com.yys.onmyoji.common.api.CommonResult;
import com.yys.onmyoji.dao.TextDao;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.CacheConfig;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
@CacheConfig(cacheNames = "text")
public class TextService {
    @Autowired
    TextDao textDao;
//    @Cacheable(keyGenerator = "keyGenerator")
    public CommonResult findAll() {
        PageHelper.startPage(1,2);
        List<Text> list = textDao.findAll();
        PageInfo pageInfo = new PageInfo(list);
//        CommonPage<Text> textCommonPage = CommonPage.restPage(list);
//        List<Text> list1 =textCommonPage.getList();
        List<Text> list1 = pageInfo.getList();
        return CommonResult.success(list1);
    }

}
